﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace InnovTech.Util.IO
{
    public static class StreamUtil
    {
        /// <summary>
        /// Creates a MemoryStream for the given string with the utf-8 encoding.
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static MemoryStream CreateStringMemoryStream(string str)
        {
            return new MemoryStream(Encoding.UTF8.GetBytes(str));
        }
        /// <summary>
        /// Gets a string from the given MemoryStream with the utf-8 encoding.
        /// </summary>
        /// <param name="ms"></param>
        /// <returns></returns>
        public static string GetStringFromMemoryStream(MemoryStream ms)
        {
            return Encoding.UTF8.GetString(ms.ToArray());
        }
    }
}
